<script setup name="Child">
import { ref } from 'vue';

const count = ref(8)
const changeCount = (n) => {
  count.value = n
}
// https://cn.vuejs.org/api/sfc-script-setup.html#defineexpose
// !使用 <script setup> 的组件是默认关闭的，需要暴露才能被外界访问
defineExpose({
  count,
  changeCount
})
</script>
<!-- <script>
import { ref } from 'vue'
export default {
  setup() {
    const count = ref(8)
    const changeCount = (n) => {
      count.value = n
    }
    return { count, changeCount }
  }
}
</script> -->
<template>
  <div>Child: {{count}}</div>
</template>
